var mWeappServiceHost = 'https://app-sjsw-proxy.fastokgo.com';

const weapi = require('../../apis/index.js')
const lmp = require('../../apis/lmp.js')
const app = getApp()
Page({
  data: {
    // 是否为iPhone类型
    isPhone: false,
    appid: '',
    appInfo: null,
    params: '',
    url: '',

  },
  onLoad(options) {
    var that = this
    that.data.appId = 'blumxgbs' // options.appid
    that.data.params = decodeURIComponent(options.params)
    wx.getSystemInfo({
      success (res) {
        console.log('系统信息', res)
        that.setData({
          isPhone: res.model.indexOf('iPhone') > -1
        })
      }
    })
  },
  onReady() {
  },
  onShow() {
    var that = this
    app.checkLogin().then(() => {
      // 应用信息
      lmp.appinfo(that.data.appId).then(res => {
        var appinfo = res.data
        console.log('应用信息', appinfo)
        // https://dev-sjsw.fastokgo.com/lmp/a39eb1e1656a3701c2f3/202402231537440052/index.html#/l/monitor
        var routeIndex = appinfo.routeIndex.substring(0, 1) == '/' ? appinfo.routeIndex : '/' + appinfo.routeIndex
        var baseUrl = ['lmp', appinfo.appId, appinfo.appVersion].join('/')
        appinfo.appIcon = weapi.server(baseUrl + '/' + appinfo.appIcon)
        var query = [
          that.data.params,
          'mediaType=' + (that.data.isPhone ? 'https_hls' : 'https_flv'),
          'token=' + weapi.getToken()
        ]
        that.setData({
          appInfo: appinfo,
          url: weapi.weapp(baseUrl + routeIndex) + '?t=' + Date.now() + '&' + query.join('&')
        })
      })
    })
  },
  onHide() {

  },
})